package cn.monkey.chat.server.admin.domain.server;

import cn.monkey.chat.server.data.Result;
import cn.monkey.chat.server.data.server.ServerVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

/**
 * ws://ip:port/ws
 * Q1、不清楚当前服务器的负载量
 * <p>
 * 1、在创建长连接之前需要获取可用的服务器
 * 2、考虑到用户的断线重连
 */
@RestController
@RequestMapping("server")
public class ServerController {

    final IServerService serverService;

    public ServerController(IServerService serverService) {
        this.serverService = serverService;
    }

    @GetMapping
    Mono<Result<ServerVo>> getServer() {
        return this.serverService.findBestServer();
    }
}
